if (LibMySQLD_INCLUDE_DIR AND LibMySQLD_LIBRARIES)
	return()
endif()

if (EXISTS ${PROJECT_SOURCE_DIR}/bundle/include/mysql/mysql.h)
	set(LibMySQLD_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/bundle/include/mysql)
	set(LibMySQLD_LIBRARY_DIR ${PROJECT_SOURCE_DIR}/bundle/lib)
	
	find_program(MYSQL_CONFIG mysql_config ${PROJECT_SOURCE_DIR}/bundle/bin
		NO_DEFAULT_PATH)
	execute_process(COMMAND ${MYSQL_CONFIG} --libmysqld-libs
		OUTPUT_VARIABLE libmysqld_libs)
	string(REGEX MATCHALL "[-]l([^ \n;])+" libmysqld_libs "${libmysqld_libs}")
	list(APPEND libmysqld_libs "-lstdc++") # required for C program
	#message("libmysqld_libs = ${libmysqld_libs}")
	set(LibMySQLD_LIBRARIES ${libmysqld_libs})
else()
	message(FATAL_ERROR "use script/mysql-embedded.build to setup MySQL embedded build environment")
endif()
